package com.wgchao;

import cn.hutool.core.util.StrUtil;
import reactor.core.publisher.Flux;

import java.util.Arrays;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @ClassName: demo1
 * @author: wgchao
 * @createTime: 2021/10/25 3:52 PM
 * @Description: TODO
 */
public class demo1 {

    public static void main(String[] args){

        Flux.range(1, 4)
                .subscribe(System.out::println,
                        error -> System.err.println("发生错误：" + error),
                        () -> System.out.println("完成"),
                        sub -> {
                            System.out.println("已订阅");
                            // 理解背压
                            // 尝试修改下 request 中的值，看看有啥变化
                            sub.request(10);
                        });
    }

}
